<template>
  <!-- 添加或修改投诉客服对话框 -->
  <el-dialog :close-on-click-modal="false" :title="formType" :visible.sync="open" @close="cancel"
             width="500px" append-to-body>
    <el-form ref="form" :model="form" :rules="rules" label-width="80px">
      <el-row>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="cancel">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
  import operationModule from '@/mixins/operation-module'
  import {
    addComplain,
    updateComplain
  } from "@/api/complain/complain";

  export default {
    name: 'add-or-update',
    mixins: [operationModule],
    data() {
      return {
        // 设置属性
        mixinOperationModuleOptions: {
          saveURL: addComplain, // 提交数据接口，api地址
          updateURL: updateComplain // 提交数据接口，api地址
        },
        moduleName: "Complain",
        open: false,
        // 弹出层标题
        //表单操作类型
        formType: this.$formType.add,
        // 表单参数
        form: {},
        // 表单校验
        rules: {
        }
      }
    },
    methods: {
      init(type) {
        this.reset()
        this.open = true
        if (type == this.$formType.add) {
        } else if (type == this.$formType.edit) {
        } else if (type == this.$formType.detail) {
        }
        this.formType = type
      },
      // 表单重置
      reset() {
        this.form = {
          id: undefined,                                                                                userId: undefined,                                                                                connectTime: undefined,                                                                                reportReason: undefined,                                                                                explainImg: undefined,                                                                                describe: undefined,                                                                                createTime: undefined,                                                                                lastupdateTime: undefined                                                }
        ;
        this.resetForm("form");
      },
      cancel() {
        this.$emit('on-close')
        this.open = false;
      }
    },
    created() {
      this.reset();
    }
  }
</script>
